// 注意：该文件由脚本自动生成 🎉🎉🎉
/**
 * @Description: 注册所有指令
 * @Author bianpengfei
 * @create 2022/11/25 18:19
 */
// @ts-nocheck
import { requireAllModule, isPlainObject, isFunction } from 'sf-utils2'
import { basename } from 'path'

const directives = requireAllModule({
  requireContext: (require as unknown as any).context('./modules', true, /\.(js|ts)$/),
  exclude: ['./modules/index.js']
}).reduce((pre, [v, k]) => {
  if (isPlainObject(v?.default)) {
    const name = basename(k, '.js')
    pre[name] = v.default
  }
  return pre
}, {})

export default {
  /**
   * 注册所有指令
   */
  install: (app) => {
    Object.entries(directives).forEach(([k, v]) => {
      app.directive(k, v)
      if (isFunction(v?.install)) {
        app.use(v)
      }
    })
  },
  /**
   * 所有指令
   */
  ...directives
}
